<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="message" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="gotoPage('/crm/sale/CustomerDet?'+vueparams+'')" type='success' size="mini"><i class='fa fa-edit'></i>修改</el-button>
          <el-button @click="d_client('')" type='danger' size="mini"><i class='fa fa-remove'></i>删除</el-button>
          <el-button @click="gotoPage('/crm/sale/CartogramMerchant?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 客户信息 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="客户分类" prop="">
                  {{message.client_class}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="客户条形码" prop="">
                  {{message.client_barcode}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="客户名称" prop="">
                  {{message.client_name}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="责任人" prop="">
                  {{message.enteredby_name}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="信息来源" prop="">
                  {{message.corigin}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="客户等级" prop="">
                  {{message.crate}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="网站地址" prop="">
                  {{message.client_net}}
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="popPotentialPhoneAdd('')" type='success' size="mini"><i class='fa fa-plus'></i>增加电话号码</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 电话号码 </span>
          </div>
          <el-table :data="phones">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="u_phones('&phones_id='+scope.row.phones_id+'')">设为主要</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="d_phone('&phones_id='+scope.row.phones_id+'')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="类型" prop="description">
            </el-table-column>
            <el-table-column label="区号" prop="phone_area">
            </el-table-column>
            <el-table-column label="号码" prop="p_no">
            </el-table-column>
            <el-table-column label="分机号码" prop="phones_extension">
            </el-table-column>
          </el-table>
          <el-button @click="popPotentialEmailAdd('')" type='success' size="mini"><i class='fa fa-plus'></i>增加电子邮件</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 电子邮件地址 </span>
          </div>
          <el-table :data="email">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="u_email('&email_id='+scope.row.email_id+'')">设为主要</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="d_email('&email_id='+scope.row.email_id+'')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="类型" prop="description">
            </el-table-column>
            <el-table-column label="邮件地址" prop="e_address">
            </el-table-column>
          </el-table>
          <el-button @click="popPotentialImmAdd('')" type='success' size="mini"><i class='fa fa-plus'></i>增加即时通讯地址</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 微信/QQ号码 </span>
          </div>
          <el-table :data="moment_info">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_moment('&CMIDcontact_id='+scope.row.contact_id+'')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="类型" prop="mccon">
            </el-table-column>
            <el-table-column label="信息" prop="mcno">
            </el-table-column>
            <el-table-column label="号码" prop="mc_no">
            </el-table-column>
          </el-table>
          <div class="form-unit">
            <span class="mvc-title-left"> 地址 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="地址类型" prop="address_type">
                  {{address.address_type}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="地区" prop="address_nation">
                  {{address.address_nation}} 省 {{address.address_province_desc}} 城市 {{address.address_city_desc}} 县 {{address.address_town_desc}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="邮政编码" prop="address_postcode">
                  {{address.address_postcode}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="详细地址" prop="address_info">
                  <div style="white-space: pre-wrap;">{{address.address_info}}</div>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="地图" prop="">
                  <baidu-map style="width:100%;height: 500px;" @ready="getMap"></baidu-map>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div class="form-unit">
            <span class="mvc-title-left"> 额外明细 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="备注" prop="">
                  {{message.client_remark}}
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="gotoPage('/crm/sale/CustomerDet?'+vueparams+'')" type='success' size="mini"><i class='fa fa-edit'></i>修改</el-button>
          <el-button @click="d_client('')" type='danger' size="mini"><i class='fa fa-remove'></i>删除</el-button>
          <el-button @click="gotoPage('/crm/sale/CartogramMerchant?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'客户信息'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="PotentialPhoneAddVisible" append-to-body>
      <PotentialPhoneAdd v-if="PotentialPhoneAddVisible" ref="PotentialPhoneAdd" :popparams="popparams"> </PotentialPhoneAdd>
    </el-dialog>
    <el-dialog :visible.sync="PotentialEmailAddVisible" append-to-body>
      <PotentialEmailAdd v-if="PotentialEmailAddVisible" ref="PotentialEmailAdd" :popparams="popparams"> </PotentialEmailAdd>
    </el-dialog>
    <el-dialog :visible.sync="PotentialImmAddVisible" append-to-body>
      <PotentialImmAdd v-if="PotentialImmAddVisible" ref="PotentialImmAdd" :popparams="popparams"> </PotentialImmAdd>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import PotentialPhoneAdd from "@/views/crm/sale/potential/PotentialPhoneAdd";
  import PotentialEmailAdd from "@/views/crm/sale/potential/PotentialEmailAdd";
  import PotentialImmAdd from "@/views/crm/sale/potential/PotentialImmAdd";
  export default {
    name: 'CustomerDets',
    components: {
      PotentialPhoneAdd,
      PotentialEmailAdd,
      PotentialImmAdd,
    },
    props: ['popparams'],
    data() {
      return {
        PotentialPhoneAddVisible: false,
        PotentialPhoneAddValue: null,
        PotentialPhoneAddDesc: null,
        PotentialEmailAddVisible: false,
        PotentialEmailAddValue: null,
        PotentialEmailAddDesc: null,
        PotentialImmAddVisible: false,
        PotentialImmAddValue: null,
        PotentialImmAddDesc: null,
        vueparams: this.getVUEParams(""),
        message: {
          client_class: null,
          client_barcode: null,
          client_name: null,
          enteredby_name: null,
          corigin: null,
          crate: null,
          client_net: null,
        },
        phones: [],
        email: [],
        moment_info: [],
        address: {
          address_type: null,
          address_nation: null,
          address_province_desc: null,
          address_city_desc: null,
          address_town_desc: null,
          address_postcode: null,
          address_info: null,
          client_remark: null,
        },
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "80299289AF2443B18EA545A4C0C37170",
        name: "客户管理右菜单",
        selected: "客户信息"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/CustomerDets/customerDets?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
          this.mvc.loadMap(this.map, this.baidumap);
        })
      },
      u_text(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerDets/u_text?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      u_moment(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerDets/u_moment?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      u_email(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerDets/u_email?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      u_phones(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerDets/u_phones?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_text(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerDets/d_text?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_moment(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerDets/d_moment?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_email(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerDets/d_email?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_phone(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerDets/d_phone?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popPotentialPhoneAdd(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.PotentialPhoneAddVisible = !this.PotentialPhoneAddVisible;
      },
      popPotentialEmailAdd(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.PotentialEmailAddVisible = !this.PotentialEmailAddVisible;
      },
      popPotentialImmAdd(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.PotentialImmAddVisible = !this.PotentialImmAddVisible;
      },
      getMap({
        BMap,
        map
      }) {
        this.map = map;
      },
    },
  }
</script>
